#include "stdafx.h"
#include "RectStatic.h"
#include "RectElement.h"
#include "PFMEngine.h"

RectStatic::RectStatic()
:m_pRectElement(NULL)
,m_fAlpha(1)
{}

RectStatic::~RectStatic()
{
	GetPFMEngine().ReleaseRect(m_pRectElement);
}

void RectStatic::Update()
{
	if( m_bShow	)
	{
		GetPFMEngine().AddDrawElement(m_pRectElement);
	}
}

void RectStatic::ChangeSize()
{
	assert(m_pRectElement != NULL);

	m_pRectElement->SetPos(float(m_nPosX), float(m_nPosY), float(m_nWidth), float(m_nHeight), m_fTexLeft, m_fTexRight, m_fTexTop, m_fTexBottom, m_fAlpha);
}

void RectStatic::Create(RectElement* pRectElement, int nPosX, int nPosY, int nWidth, int nHeight)
{
	m_pRectElement	= pRectElement;	
	m_nPosX			= nPosX;
	m_nPosY			= nPosY;
	m_nWidth		= nWidth;
	m_nHeight		= nHeight;

	ChangeSize();
}

void RectStatic::SetTexture(const char* pPath)
{
	assert(m_pRectElement != NULL);

	GetPFMEngine().ChangeRectTexture(m_pRectElement, pPath);	
}